package club.ljwang.service;

import club.ljwang.dao.MemberMapper;
import club.ljwang.pojo.Member;
import com.alibaba.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @Auther: wangl
 * @Date: 2020/3/5 16:45
 * @Description:
 */

@Service(interfaceClass = MemberService.class)
@Transactional
public class MemberServiceImpl implements MemberService {

    @Autowired
    private MemberMapper memberMapper;

    @Override
    public Member findTelephone(String telephone) {

        return memberMapper.findByTelephone(telephone);
    }

    @Override
    public Member add(Member member) {
        member.setId( memberMapper.add(member));
        return member;
    }

    @Override
    public List<Member> getFamily(Integer id) {
        //查询当前用户的家庭成员
        List<Member> members = memberMapper.getFamily(id);

        //查询当前登入的用户
        Member member = memberMapper.findById(id);
        members.add(member);

        return members;
    }
}
